package com.kordar.admin.modular.sys.formatter;

import com.kordar.admin.enums.EnumUtils;
import com.kordar.admin.kernel.util.HtmlUtil;
import com.kordar.admin.kernel.util.LayuiHelper;
import com.kordar.admin.modular.sys.enums.MenuPosition;
import com.kordar.datalist.formatter.Formatter;

import java.util.HashMap;
import java.util.Map;

public class MenuLayuiPosFormatter implements Formatter<String> {
    @Override
    public String format(Object value, Object... params) {
        Integer key = (Integer) value;
        Map<String, String> options = new HashMap<>();
        options.put("class", "layui-badge " + LayuiHelper.bgColor(key));
        return HtmlUtil.tag("i", EnumUtils.ValueByCode(MenuPosition.class, key), options);
    }
}
